package 语雀题目21至55;

import java.util.Scanner;

/**
 * ClassName: 判断字符串是否回文
 * Package: 语雀21至40
 * Description:回文字符串是指一个字符串正读和反读都相同的字符串。写一个程序判断从键盘输入的字符串是不是回文字符串。
 *
 * @Author fjorid
 * @Create 2025/1/6 15:13
 * @Version 1.0
 */
public class 判断字符串是否回文21 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //从键盘获取一串字符串
        System.out.println("请输入一串字符串");
        String character = scan.nextLine();
        //判断该字符串是不是回文字符串
        int count = 0;
        for (int i = 0; i < character.length()/2; i++) {
            if(character.charAt(i) == character.charAt(character.length()-1-i)){
               count++;
            }

        }
      if(count == character.length()/2)  {
          System.out.println(character+"是回文字符串");
      }else {
          System.out.println(character+"不是回文字符串");
      }
    }
}
